package com.ruoyi.web.customerclass.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.customerclass.domain.Customerclass;
import com.ruoyi.web.customerclass.service.ICustomerclassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * customerclassController
 * 
 * @author ruoyi
 * @date 2024-09-29
 */
@RestController
@RequestMapping("/customerclass/customerclass")
public class CustomerclassController extends BaseController
{
    @Autowired
    private ICustomerclassService customerclassService;

    /**
     * 查询customerclass列表
     */
    @PreAuthorize("@ss.hasPermi('customerclass:customerclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(Customerclass customerclass)
    {
        startPage();
        List<Customerclass> list = customerclassService.selectCustomerclassList(customerclass);
        return getDataTable(list);
    }

    /**
     * 导出customerclass列表
     */
    @PreAuthorize("@ss.hasPermi('customerclass:customerclass:export')")
    @Log(title = "customerclass", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Customerclass customerclass)
    {
        List<Customerclass> list = customerclassService.selectCustomerclassList(customerclass);
        ExcelUtil<Customerclass> util = new ExcelUtil<Customerclass>(Customerclass.class);
        util.exportExcel(response, list, "customerclass数据");
    }

    /**
     * 获取customerclass详细信息
     */
    @PreAuthorize("@ss.hasPermi('customerclass:customerclass:query')")
    @GetMapping(value = "/{cCCCode}")
    public AjaxResult getInfo(@PathVariable("cCCCode") String cCCCode)
    {
        return success(customerclassService.selectCustomerclassByCCCCode(cCCCode));
    }

    /**
     * 新增customerclass
     */
    @PreAuthorize("@ss.hasPermi('customerclass:customerclass:add')")
    @Log(title = "customerclass", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Customerclass customerclass)
    {
        return toAjax(customerclassService.insertCustomerclass(customerclass));
    }

    /**
     * 修改customerclass
     */
    @PreAuthorize("@ss.hasPermi('customerclass:customerclass:edit')")
    @Log(title = "customerclass", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Customerclass customerclass)
    {
        return toAjax(customerclassService.updateCustomerclass(customerclass));
    }

    /**
     * 删除customerclass
     */
    @PreAuthorize("@ss.hasPermi('customerclass:customerclass:remove')")
    @Log(title = "customerclass", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cCCCodes}")
    public AjaxResult remove(@PathVariable String[] cCCCodes)
    {
        return toAjax(customerclassService.deleteCustomerclassByCCCCodes(cCCCodes));
    }
}
